﻿#pragma once

#ifndef ARD_LOG_H
#define ARD_LOG_H

#ifdef __cplusplus
extern "C"
{
#endif // __cpluscplus

#ifdef _DEBUG

#define LOGTIME "%Y-%m-%d %H:%M:%S."

///临时使用
#define LogZ(x) do{\
	std::unique_lock<std::mutex> lock(logMtx);\
	std::cout<<get_format_time(LOGTIME)<<" ["<<std::dec<<std::setw(5)<<std::this_thread::get_id()<<"]: D " TAG": "<< x << std::endl;}\
	while (0)

	///加空格去掉红线警告
	//printf("D " TAG":" format"\n", ##__VA_ARGS__);}
	// 获取当前时间
	 // 转换为本地时间
#define LogD(x) do{\
	std::unique_lock<std::mutex> lock(logMtx);\
	std::cout<<get_format_time(LOGTIME)<<" ["<<std::dec<<std::setw(5)<<std::this_thread::get_id()<<"]: D " TAG": "<< x << std::endl;}\
	while (0)

#define LogI(x) do{\
	std::unique_lock<std::mutex> lock(logMtx);\
	std::cout<<get_format_time(LOGTIME)<<" ["<<std::dec<<std::setw(5)<<std::this_thread::get_id()<<"]: I " TAG": "<< x << std::endl;}\
	while (0)

#define LogW(x) do{\
	std::unique_lock<std::mutex> lock(logMtx);\
	std::cout<<get_format_time(LOGTIME)<<" ["<<std::dec<<std::setw(5)<<std::this_thread::get_id()<<"]: W " TAG": "<< x << std::endl;}\
	while (0)

#define LogE(x) do{\
	std::unique_lock<std::mutex> lock(logMtx);\
	std::cout<<get_format_time(LOGTIME)<<" ["<<std::dec<<std::setw(5)<<std::this_thread::get_id()<<"]: E " TAG": "<< x << std::endl;}\
	while (0)

#define LogAD(x) do{\
	std::unique_lock<std::mutex> lock(logMtx);\
	std::cout<<get_format_time(LOGTIME)<<"D FILE:" __FILE__", LINE:"<<std::dec<<__LINE__<<":"<< x << std::endl;}\
	while (0)

#else

#define LogD(x) 

#define LogI(x)

#define LogW(x) 

#define LogE(x)

#define LogAD(x)

#endif // _DEBUG


#ifdef __cplusplus
}
#endif // __cpluscplus

#endif // !ARD_LOG_H


